package  
{
	import flash.display.Graphics;
	import flash.display.Sprite;
	import flash.geom.Point;
	/**
	 * ...
	 * @author Arthas
	 */
	public class Chart extends Sprite
	{
		
		
		
		
		private var point_container:Sprite;
		private var line_container:Sprite;
		private var scaleplate_container:Sprite;
		
		
		//private var line_style;
		
		public function Chart(_width:int,_height:int) 
		{
			this.graphics.beginFill(0x2f2f2f);
			this.graphics.drawRect(0, 0, _width, _height);
			this.graphics.endFill();
			
			scaleplate_container  = new Sprite();
			point_container = new Sprite();
			line_container = new Sprite();
			
			this.addChild(scaleplate_container);
			this.addChild(line_container);
			this.addChild(point_container);
		}
		
		
		
		private var list:Array = [];
		
		
		public function add(point:Point):void {
			drawPoint(point);
			drawLine(point);
			list.push(point);
		}
		
		private function drawPoint(point:Point):void {
			var c_point:ChartPoint = new ChartPoint();
			c_point.x = point.x;
			c_point.y = point.y;
			point_container.addChild(c_point);
		}
		
		private function drawLine(point:Point):void {
			var last_point:Point = list[list.length - 1];
			if (last_point) {
				var line_graphics:Graphics = line_container.graphics;
				line_graphics.lineStyle(2, 0xFFFFFF, 1);
				line_graphics.beginFill(0xFFFFFF);
				line_graphics.moveTo(last_point.x, last_point.y);
				line_graphics.lineTo(point.x, point.y);
				line_graphics.endFill();
			}
		}
		
		
	}

}